package com.larry.etl;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @ProjectName hadoop
 * @Author larry
 * @Date 14:03 2021/11/25
 * @Description TODO
 **/
public class ETLMapper extends Mapper<LongWritable, Text,Text, NullWritable> {

    private Text outK = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String result = ETLUtil.etl(line);
        if (result == null){
            return;
        }
        outK.set(result);

        context.write(outK,NullWritable.get());
    }
}
